fix(rust): unblock four adaptive-sampling parametric tests#7007
Draft
bm1549 wants to merge 1 commit into
Draft
Conversation
Enables tests that now pass with the adaptive-sampling precedence fix and DD_TRACE_SAMPLE_RATE support shipped in dd-trace-rs PR #227: - TestDynamicConfigSamplingRules::test_trace_sampling_rules_override_rate - TestDynamicConfigSamplingRules::test_trace_sampling_rules_with_tags - TestDynamicConfigV1::test_trace_sampling_rate_override_env - TestDynamicConfigV1::test_trace_sampling_rate_with_sampling_rules The Rust tracer now: - Respects the documented multi-source precedence (env rules survive an RC-rate-only update; the synthetic catch-all built from tracing_sampling_rate uses default provenance, DM -3). - Parses DD_TRACE_SAMPLE_RATE as a global catch-all rate. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Contributor
|
|
|
gh-worker-dd-mergequeue-cf854d Bot
pushed a commit
to DataDog/dd-trace-rs
that referenced
this pull request
Jun 1, 2026
) # What does this PR do? Fixes adaptive-sampling Remote Config in `datadog-opentelemetry`, rebuilt on top of PR #154. Also adds `DD_TRACE_SAMPLE_RATE` support. Before this PR, four things were broken: 1. **`tracing_sampling_rate` from RC was ignored.** The handler only acted on `tracing_sampling_rules`; a rate-only payload installed nothing. 2. **RC list-shape `tags` were rejected.** RC encodes `tags` as `[{"key": "env", "value_glob": "prod"}]`, but `libdd_sampling::SamplingRuleConfig::tags` only accepted the map shape, so the parse errored and the whole update was dropped. 3. **Env `DD_TRACE_SAMPLING_RULES` were wiped on every RC update.** `update_sampling_rules_from_remote` does a full override, so any RC change replaced env rules, even when RC only sent a global rate. 4. **`DD_TRACE_SAMPLE_RATE` had no effect.** No binding existed. # Motivation End-to-end adaptive sampling didn't work. # What changed **Composition.** `ApmTracingHandler::process_config` now follows the multi-source precedence model: | env rules | env `DD_TRACE_SAMPLE_RATE` | RC `tracing_sampling_rules` | RC `tracing_sampling_rate` | Effective rule chain | |---|---|---|---|---| | present | any | absent / null | absent / null | `env_rules` | | present | unset | absent / null | present | `env_rules + catch_all(rc_rate)` | | present | set | absent / null | absent / null | `env_rules + catch_all(env_rate)` | | present | set | absent / null | present | `env_rules + catch_all(rc_rate)` | | any | any | non-empty array | absent / null | `rc_rules + catch_all(env_rate)` if env_rate set | | any | any | non-empty array | present | `rc_rules + catch_all(rc_rate)` | The synthetic catch-all uses libdatadog's default provenance, mapping to DM `-3` (LOCAL_USER). See the "legacy behavior" comment in [test_trace_sampling_rules_override_rate](https://github.com/DataDog/system-tests/blob/main/tests/parametric/test_dynamic_configuration.py#L872). **`DD_TRACE_SAMPLE_RATE`.** New `Config::trace_sample_rate(): Option<f64>`. When set, the sampler installs an implicit catch-all so `DD_TRACE_RATE_LIMIT` applies. Unset means no catch-all (libdatadog's no-rule path samples at 100%). **Tag normalization.** RC encodes `tags` as the list shape `[{"key", "value_glob"}]`. This is parsed natively by `libdd-sampling` ≥ 2.1.0 (DataDog/libdatadog#2033), so this PR bumps `libdd-sampling` 1.0.0 → 2.1.0 (pulling `libdd-common` → 4.2.0) and no in-tracer normalization is needed. An earlier revision carried a `normalize_rc_tags` shim for this; it has been removed now that the upstream release is available. Regression coverage: `test_handler_rc_rules_with_list_tags_applied` (list-shape tags apply, tags preserved as a map) and `test_handler_malformed_tags_rejects_update` (malformed list entries still rejected wholesale, not silently broadened). **Fail-closed behavior.** When libdatadog rejects an update (malformed tags, out-of-range rate), `process_config` returns `Err` so the RC dispatcher reports `apply_state=3` and the prior policy survives. Out-of-range RC `tracing_sampling_rate` (outside `[0.0, 1.0]`) and non-numeric values are rejected up-front. **Env/code rate validation.** `DD_TRACE_SAMPLE_RATE` (and the programmatic `set_trace_sample_rate`) get the same range check: only finite values in `[0.0, 1.0]` are honored; out-of-range values are logged and treated as unset rather than installed as a catch-all rule that libdatadog would clamp (negative ⇒ drop all, > 1.0 ⇒ keep all). **Target check.** A config's `service_target` is honored before applying: a payload whose specific (non-`*`) `service`/`env` doesn't match this tracer — primary service or an advertised extra service, compared case-insensitively — is ignored, so a mistargeted RC delivery can never change this service's sampling. Mirrors dd-trace-py/go. # Additional Notes - Four parametric tests unblocked by this PR. Companion PR DataDog/system-tests#7007. - Coordinated with @iunanua's PR #222 (libdatadog RC client wiring). #227 lands first; #222 rebases on top. Co-authored-by: brian.marks <brian.marks@datadoghq.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
Enables four parametric tests for Rust now that DataDog/dd-trace-rs#227 fixes the underlying precedence and adds
DD_TRACE_SAMPLE_RATEsupport.What does this PR do?
Removes four
missing_featureentries frommanifests/rust.yml:TestDynamicConfigSamplingRules::test_trace_sampling_rules_override_rateTestDynamicConfigSamplingRules::test_trace_sampling_rules_with_tagsTestDynamicConfigV1::test_trace_sampling_rate_override_envTestDynamicConfigV1::test_trace_sampling_rate_with_sampling_rulesDo not merge before DataDog/dd-trace-rs#227
The parametric scenario runs against both the dd-trace-rs
mainbuild (rust dev) and the released crates.io version (rust prod). Both fail on these four tests until dd-trace-rs#227 lands.Sequence:
rust devgoes green.rust prodalso goes green.Test plan
mainbuild after Fix ARM node #227 merges.